﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Nova_DAL;
using System.Data.Common;
using System.Data;
using Nova_Common;

public partial class System_System_OrgCode : System.Web.UI.Page
{
    DataSet ds = new DataSet();
    DbHelper dbHelper = new DbHelper();
    DbCommand cmd = null;
    string strSQL = "";
    int iFlag = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    protected void Bind()
    {
        strSQL = "SELECT * FROM TB_ORGCODE";
        cmd = dbHelper.GetSqlStringCommond(strSQL);
        ds = dbHelper.ExecuteDataSet(cmd);
        txt_OrgCode.Text = ds.Tables[0].Rows[0]["id"].ToString();
    }

    protected void ibtnSubmit_Click(object sender, ImageClickEventArgs e)
    {
        if (txt_OrgCode.Text.ToString().Trim() == "")
        {
            ShowBox.MessageBox(this.Page, "公司编号不允许为空！");
        }
        else
        {
            strSQL = "UPDATE TB_ORGCODE SET ID='" + txt_OrgCode.Text.ToString().Trim() + "'";
            cmd = dbHelper.GetSqlStringCommond(strSQL);
            iFlag = dbHelper.ExecuteNonQuery(cmd);
            if (iFlag > 0)
            {
                ShowBox.MessageBox(this.Page, "修改成功！");
                Bind();
            }
        }
    }
}
